//------------------------------------------------------------------------------
//!	@file debug.h
//!	@brief
//!		Debug output driver, debug macros ASSERT & TRACE declaration file
//!
//!  $Id: debug.h 175 2013-03-21 05:36:02Z ac.verbeck@gmail.com $
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
//	Copyright and Disclaimer Notice
//
//  All information contained herein is the property of Marshall Electronics, Inc.
//  And are protected trade secrets and copyrights, and may be covered by U.S.
//  and/or foreign patents or patents pending and/or mask works.
//
//  Any reproduction, dissemination or use of any portion of this
//  document or of software or other works derived from it is strictly
//  forbidden unless prior written permission is obtained from
//  Marshall Electronics.
//
//  Software Patents Pending.
//------------------------------------------------------------------------------
#pragma once

//------------------------------------------------------------------------------
//	TRACE enums
//------------------------------------------------------------------------------
typedef	enum TRACE_LEVELtag	{
    ALL			= 0,
    INFO		= 10,		//  Blue
    DEBUG		= 20,		//  Green
    WARNING		= 30,		//  Yellow
    DEVELOP		= 40,		//  Magenta
    CRITICAL	= 50,		//  Red
    NONE		= 100
} TRACE_LEVEL;

//------------------------------------------------------------------------------
//  Debug:
//  TRACE             Prints debug message and continues.
//  ASSERT            Notifies user of ASSERT.
//  ASSERT_CRITICAL   Notifies user of ASSERT_CRITICAL.
//                    Halts after assert.
//------------------------------------------------------------------------------
void _TR(TRACE_LEVEL lvl_trace,	char* File, int Line, ...);

#ifdef BLD_DEBUG /* { */
#define	TRACE(tl,...)		_TR(tl,__FILE__, __LINE__, __VA_ARGS__);

#define	ASSERT(x)			if (!(x))															\
								{																	\
									_TR(WARNING, __FILE__, __LINE__, "Assert failed!");				\
								}

#define	FAIL()				_TR(WARNING, __FILE__, __LINE__, "Fail asserted!");

#define	ASSERT_CRITICAL(x)	if (!(x))															\
								{																	\
									_TR(CRITICAL, __FILE__,	__LINE__, "Critical Assert failed!");	\
								}

#define FAIL_CRITICAL()		_TR(CRITICAL, __FILE__,	__LINE__, "Critical Fail Asserted!");

#else /* }{ */
#define	TRACE(tl,...)			;
#define	ASSERT(x)				;
#define	FAIL()					;
#define	ASSERT_CRITICAL(x)		;
#define	FAIL_CRITICAL()			;
#endif /* }*/

//
//	End: debug.h
//
